//
//  XS_PlanTodayItemCell.swift
//  XueDao
//
//  Created by Mac on 2020/12/15.
//

import UIKit

protocol XS_PlanTodayItemCellDelegate {
    func todayItemCell(todayItemCell : XS_PlanTodayItemCell, didClickLearnBtn:UIButton)
}

class XS_PlanTodayItemCell: UICollectionViewCell {
    
    var delegate : XS_PlanTodayItemCellDelegate?

    @IBOutlet weak var titleBtn: QMUIButton!
    @IBOutlet weak var titleLabel: UILabel!
    @IBOutlet weak var learnBtn: UIButton!
    @IBOutlet weak var timeLabel: UILabel!
    
    var _model : XS_CourseItemModel!
    public var model : XS_CourseItemModel!{
        set{
            _model = newValue
            //设置数据
            titleBtn.setTitle(newValue.curriculumName, for: .normal)
            titleBtn.titleEdgeInsets = UIEdgeInsets.init(top: 0, left: 5, bottom: 0, right: 0)
            timeLabel.text = newValue.curriculumTime
            titleLabel.text = newValue.hourName
        }
        get{
            return _model
        }
    }
    
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
        titleBtn.imagePosition = .right
        titleBtn.spacingBetweenImageAndTitle = 8
        learnBtn.layer.borderWidth = 1
        learnBtn.layer.borderColor = UIColor.qmui_color(withHexString: "#2ABD9C")?.cgColor
    }

    @IBAction func learnBtnAction(_ sender: UIButton) {
        if delegate != nil {
            delegate?.todayItemCell(todayItemCell: self, didClickLearnBtn: sender)
        }
    }
}
